import {createRouter, createWebHashHistory} from 'vue-router'

const routerHistory = createWebHashHistory();
const router = createRouter({
    history: routerHistory,
    routes: [
        {
            path: '/',
            meta: {title: '电子地图'},
            component: () => import('../view/home/index.vue')
        },
        {
            path: '/forewarning',
            meta: {title: '告警预警'},
            component: () => import('../view/forewarning/index.vue')
        },
        {
            path: '/alarmQuery',
            meta: {title: '告警查询'},
            component: () => import('../view/alarmQuery/index.vue')
        },
        {
            path: '/log',
            meta: {title: '操作日志'},
            component: () => import('../view/log/index.vue')
        },
        {
            path: '/camera/list',
            meta: {title: '摄像头列表'},
            component: () => import('../view/camera/list/index.vue')
        },
        {
            path: '/camera/detail',
            meta: {title: '摄像头设置'},
            component: () => import('../view/camera/detail/index.vue')
        },
        {
            path: '/camera/add',
            meta: {title: '摄像头添加'},
            component: () => import('../view/camera/add/index.vue')
        },
        {
            path: '/user/list',
            meta: {title: '用户管理'},
            component: () => import('../view/user/list/index.vue')
        },
        {
            path: '/statistics',
            meta: {title: '数据统计'},
            component: () => import('../view/statistics/index.vue')
        },
        {
            path: '/alarmSetting',
            meta: {title: '告警设置'},
            component: () => import('../view/alarmSetting/index.vue')
        },
        {
            path: '/systemManagement',
            meta: {title: '系统管理'},
            component: () => import('../view/systemManagement/index.vue')
        },
        {
            path: '/errorInfo',
            meta: {title: '故障信息管理'},
            component: () => import('../view/errorInfo/index.vue')
        },
        {
            path: '/organization',
            meta: {title: '组织机构管理'},
            component: () => import('../view/organization/index.vue')
        },
        {
            path: '/login',
            meta: {title: '登录'},
            component: () => import('../view/login/index.vue')
        },
    ]
})
router.beforeEach((to, from, next) => {
    // 如果路由元信息中存在标题，则设置为文档标题
    if (to.meta && to.meta.title) {
        //document.title = to.meta.title + ' - 智慧运维视频监控智能分析系统';
        document.title = to.meta.title;
    }
    next(); // 确保继续导航
});

export default router
